import { h } from 'vue';
import { NTag } from 'naive-ui';
import { FormSchema } from '@/components/Form';

export const columns = [
  {
    type: 'selection',
    key: 'selection',
  },
  {
    title: 'ID',
    key: 'id',
    width: 70,
  },
  {
    title: '渠道标识',
    key: 'chanId',
    width: 200,
  },
  {
    title: '渠道昵称',
    key: 'chanName',
  },
  {
    title: '游戏昵称',
    key: 'gameName',
  },
  {
    title: '渠道等级',
    key: 'chanLevel',
    render(row) {
      return row.chanLevel == 'First'
        ? '一级渠道'
        : row.chanLevel == 'Second'
        ? '二级渠道'
        : row.chanLevel == 'Thrid'
        ? '三级渠道'
        : '四级渠道';
    },
  },
  {
    title: '红包状态',
    key: 'hasReflectbtn',
    render(row) {
      return h(
        NTag,
        {
          type: row.hasReflectbtn == 'able' ? 'success' : 'error',
        },
        {
          default: () => (row.hasReflectbtn == 'able' ? '启用' : '禁用'),
        }
      );
    },
    width: 90,

  },
  {
    title: '渠道状态',
    key: 'chanStatus',
    render(row) {
      return h(
        NTag,
        {
          type: row.chanStatus == 'able' ? 'success' : 'error',
        },
        {
          default: () => (row.chanStatus == 'able' ? '启用' : '禁用'),
        }
      );
    },
    width: 90,

  },
  {
    title: '排行榜状态',
    key: 'rankStatus',
    render(row) {
      return h(
        NTag,
        {
          type: row.rankStatus == 'able' ? 'success' : 'error',
        },
        {
          default: () => (row.rankStatus == 'able' ? '启用' : '禁用'),
        }
      );
    },
    width: 90,
  },
  {
    title: '落地页',
    key: 'chanDesc',
    render(row) {
      //https://dl.whdjgame.cn/?dt=aaasdasdw
      if (row.chanDesc.length > 0) {
        return 'https://dl.whdjgame.cn?dt=' + row.chanId;
      }
    },
  },
  {
    title: '创建时间',
    key: 'createTime',
  },
];
export const addCloumns: FormSchema[] = [
  {
    field: 'chanName',
    component: 'NInput',
    label: '渠道昵称',
    componentProps: {
      placeholder: '渠道昵称',
    },
    rules: [{ required: true, message: '请输入渠道昵称', trigger: ['blur'] }],
  },
  {
    field: 'chanLevel',
    label: '渠道等级',
    rules: [{ required: true, message: '请选择渠道等级', trigger: ['blur'] }],
    slot: 'chanLevelSelect',
  },
  {
    field: 'gameId',
    label: '关联游戏',
    rules: [{ required: true, message: '请选择关联游戏', trigger: ['blur'] }],
    slot: 'gameSelect',
  },
  {
    field: 'hasReflectbtn',
    label: '红包开关',
    component: 'NSwitch',
    defaultValue: true,
  },
  {
    field: 'chanStatus',
    label: '渠道状态',
    component: 'NSwitch',
    defaultValue: true,
  },
  {
    field: 'rankStatus',
    label: '排行榜状态',
    component: 'NSwitch',
    defaultValue: false,
  },
];

export const bindCloumns: FormSchema[] = [
  {
    field: 'chanName',
    component: 'NInput',
    label: '渠道昵称',
    componentProps: {
      placeholder: '渠道昵称',
      disabled: true,
    },
  },
  {
    field: 'gameId',
    label: '关联游戏',
    rules: [{ required: true, message: '请选择关联游戏', trigger: ['blur'] }],
    slot: 'gameSelect',
  },
];

export const bindAnchorCloumns: FormSchema[] = [
  {
    field: 'anchorId',
    label: '关联主播',
    // rules: [{required: true, message: '请选择关联主播', trigger: ['blur']}],
    slot: 'anchorSelect',
  },
];

export const bindDownloadCloumns: FormSchema[] = [
  {
    field: 'url',
    component: 'NInput',
    label: '下载链接',
    componentProps: {
      placeholder: '下载链接',
    },
  },
  {
    field: 'cmd',
    component: 'NInput',
    label: '红包口令',
    componentProps: {
      placeholder: '红包口令',
    },
  },
];
